dotConnect for DB2 Documentation
Devart.Common Namespace / DbDataTable Class / FillPage Method / FillPage(Int32,Int32,Object[]) Method
The number of the first row to retrieve. Value 0 means the first row, 1 means the second, and so on.
The maximum number of records to retrieve.
Used to fill the System.Data.IDbCommand.Parameters collection of the SelectCommand property.
Example

In This Topic
    FillPage(Int32,Int32,Object[]) Method
    In This Topic
    Fills the System.Data.DataTable.Rows collection of the DbDataTable with rows from the data source starting at the row indicated by startRecord and including up to the number of rows indicated by maxRecords using the parameter values passed in parameterValues.
    Syntax
    'Declaration
     
    Public Overloads Function FillPage( _
       ByVal startRecord As Integer, _
       ByVal maxRecords As Integer, _
       ByVal parameterValues() As Object _
    ) As Integer
    public int FillPage( 
       int startRecord,
       int maxRecords,
       object[] parameterValues
    )

    Parameters

    startRecord
    The number of the first row to retrieve. Value 0 means the first row, 1 means the second, and so on.
    maxRecords
    The maximum number of records to retrieve.
    parameterValues
    Used to fill the System.Data.IDbCommand.Parameters collection of the SelectCommand property.

    Return Value

    The number of rows successfully added to or refreshed in the DbDataTable. This does not include rows affected by statements that do not return rows.
    Remarks
    This method clears any exisiting rows in the DbDataTable.
    Example
    This sample shows how to use paged access to data. It attempts to read rows 3 through 12 from the table and to display them. However, if quantity of records that match condition in the table is less than 12, only available rows will be filled into DbDataTable. Number of rows actually added is rendered to console.
    public void FillDataTable(DbDataTable myDataTable, IDbConnection myConnection, IDbDataParameter myParameter)
    {
      myDataTable.Connection = myConnection;
      myDataTable.SelectCommand = myConnection.CreateCommand();
      myDataTable.SelectCommand.CommandText = "SELECT EmpNo, EName FROM Emp WHERE DeptNo=:DeptNo";
      myParameter.ParameterName = "DeptNo";
      myDataTable.SelectCommand.Parameters.Add(myParameter);
      object[] myParamValue = new object[1];
      myParamValue[0] = 10;
      try
      {
        myDataTable.FillPage(2,10,myParamValue);
        foreach(DataRow myRow in myDataTable.Rows)
        {
          foreach(DataColumn myCol in myDataTable.Columns)
          {
            Console.Write(myRow[myCol]+"\t");
          }
          Console.WriteLine();
        }
      }
      finally
      {
        myDataTable.Clear();
      }
    }
    Public Sub FillDataTable(ByVal myDataTable As DbDataTable, ByVal myConnection As IDbConnection, ByVal myParameter As IDbDataParameter)
      myDataTable.Connection = myConnection
      myDataTable.SelectCommand = myConnection.CreateCommand()
      myDataTable.SelectCommand.CommandText = "SELECT EmpNo, EName FROM Emp WHERE DeptNo=:DeptNo"
      myParameter.ParameterName = "DeptNo"
      myDataTable.SelectCommand.Parameters.Add(myParameter)
      Dim myParamValue() As Object = {10}
      Try
        myDataTable.FillPage(2, 10, myParamValue)
        Dim myRow As DataRow
        Dim myCol As DataColumn
        For Each myRow In myDataTable.Rows
          For Each myCol In myDataTable.Columns
            Console.Write(myRow(myCol) & Chr(9))
          Next myCol
          Console.WriteLine()
        Next myRow
      Finally
        myDataTable.Active = False
      End Try
    End Sub
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also